package net.oschina.simpleplus.entity;

import java.util.UUID;

import org.apache.shiro.crypto.hash.Md5Hash;

public class User {

	private Integer id;
	private String email;
	private String nickname;
	private String passwd;
	private String salt;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getPasswd() {
		return passwd;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public static User createNewUser(String email, String passwd2) {
		String salt = UUID.randomUUID().toString().replaceAll("-", "");
		String passwd = new Md5Hash(passwd2, email+"_"+salt, 2).toHex();
		User user = new User();
		user.setEmail(email);
		user.setNickname(email);
		user.setPasswd(passwd);
		user.setSalt(salt);
		return user;
	}
	
}
